import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { WeaponUpService } from './weapon-up.service';
import { CreateWeaponUpDto } from './dto/create-weapon-up.dto';
import { UpdateWeaponUpDto } from './dto/update-weapon-up.dto';
import { PageQuery } from '../../../util/entity/page.entity';
import { Role } from '../../admin/role/entities/role.entity';

@Controller()
export class WeaponUpController {
  constructor(private readonly weaponUpService: WeaponUpService) {}

  @Post()
  create(@Body() createWeaponUpDto: CreateWeaponUpDto) {
    return this.weaponUpService.create(createWeaponUpDto);
  }

  /**
   * 获取下一个等级的信息
   */
  @Post('next')
  getNext(@Body() nextWeaponUp: { weaponType: number; level: number }) {
    return this.weaponUpService.getNext(nextWeaponUp);
  }

  @Post('list')
  findAll(@Body() pageQuery: PageQuery<Role>) {
    return this.weaponUpService.findAll(pageQuery);
  }

  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.weaponUpService.findOne(id);
  }

  @Patch(':id')
  update(
    @Param('id') id: number,
    @Body() updateWeaponUpDto: UpdateWeaponUpDto,
  ) {
    return this.weaponUpService.update(id, updateWeaponUpDto);
  }

  @Delete(':id')
  remove(@Param('id') id: number) {
    return this.weaponUpService.remove(id);
  }
}
